//
//  NumberSearchResultVC.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/7/25.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "NumberSearchResultVC.h"
#import "NumberSearchCell.h"
@interface NumberSearchResultVC ()

@end

@implementation NumberSearchResultVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    self.view.backgroundColor = [UIColor clearColor];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"NumberSearchCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
}

- (void)viewWillLayoutSubviews {
    self.tableView.frame = CGRectMake(0,kNavigationBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kNavigationBarHeight);
}
- (NSMutableArray *)searchResultArr {
    if (!_searchResultArr) {
        _searchResultArr = [[NSMutableArray alloc] init];
    }
    return _searchResultArr;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.searchResultArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NumberSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    ScenicPoint *model = self.searchResultArr[indexPath.row];
    
    [cell configDataWith:model];
    return cell;
}


- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 65;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    ScenicPoint *point = self.searchResultArr[indexPath.row];
    
    if (_delegate && [_delegate respondsToSelector:@selector(selectSenicPoint:)]) {
        
         [_delegate selectSenicPoint:point];
    }
   
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
